package com.app.dao;

import com.app.bean.ProjectBean;
import org.apache.log4j.Logger;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import java.util.List;
/**
 * User: Murilo
 * Date: 12/7/11
 * Time: 2:26 PM
 */
public class ProjectDAO extends HibernateDaoSupport {

    private static final Logger log = Logger.getLogger(ProjectDAO.class);
    /**
     * This method is resposible to save a new project or update a project in the data base
     * @param bean
     */
    public void saveProject(ProjectBean bean){
        getSession().saveOrUpdate(bean);
    }
    /**
     * This is resposible to return all the project by type
     * @param projectType
     * @return List<ProjectBean>
     */
    public List<ProjectBean> getProjects(String projectType){
        List<ProjectBean> result = (List<ProjectBean>) getSession().createCriteria(ProjectBean.class)
                .add(Restrictions.eq("projectType",projectType));
        return result;
    }


}